#!/usr/bin/env python

import os, sys
import mad
import glob, math

def executecmd(cmdstring):
	print cmdstring
	os.system(cmdstring)
	
 
if (len(sys.argv) > 1):
	path = sys.argv[1]
else:
	path = '.'

for infile in glob.glob( os.path.join(path, '*.mpg') ):	

	# set filename
	workingfileprefix = infile[0:len(infile)-4]
	print(workingfileprefix)

	#trimvid
	executecmd(('~/dev/vidscripts/extractaudio.py %s.mpg %s.mp3') % (workingfileprefix, workingfileprefix))
		
print "Done."


